﻿<?php 
if($lang == "deen" || $lang == "ende" ){
if(count($WordsLike)<0){
	return;
}
echo '
<div class="datagrid">
	<table>
	<thead>
		<tr>
			<th>ID</th>
			';
		if($lang=="deen"){
			echo '<th>Deutsch</th>
				  <th>Englisch</th>';
		}else{
			echo '<th>Englisch</th>
				  <th>Deutsch</th>';
			}
		echo '
		</tr>
	</thead>
	<tfoot>
		<tr>
			<td colspan="4">
				<div id="paging">
				<ul>
					<li><a href="#"><span>Previous</span></a></li>
					<li><a href="#" class="active"><span>1</span></a></li>
					<li><a href="#"><span>2</span></a></li>
					<li><a href="#"><span>3</span></a></li>
					<li><a href="#"><span>4</span></a></li>
					<li><a href="#"><span>5</span></a></li>
					<li><a href="#"><span>Next</span></a></li>
				</ul>
				</div>
		</tr>
	</tfoot>
	
	<tbody>';
	$j=1;
	foreach($WordsLike as $term){
		if(($j%2)==1)
			echo "<tr'>";
		else
			echo "<tr class='alt'>";
		$term["MeanWord"] = str_replace('[','<font class="InvisialbeWord">',$term["MeanWord"]);
		$term["MeanWord"] = str_replace(']','</font>',$term["MeanWord"]);
		$term["MeanWord"] = str_replace(':__:verb','',$term["MeanWord"]);
		$term["MeanWord"] = str_replace(':__:noun','',$term["MeanWord"]);
		$term["word"] = str_replace($wordSearch.' ','<b><font style="color: #F80000;">'.$wordSearch.' </font></b>',$term["word"]);
		$term["word"] = str_replace(ucfirst($wordSearch).' ','<b><font style="color: #F80000;">'.ucfirst($wordSearch).' </font></b>',$term["word"]);
		
		
		echo "
				<td>".$j."</td>
				<td>".$term["word"]."</td> 
				<td>".$term["MeanWord"]."</td> 
			</tr>";
		$j++;
		}
	echo "</tbody>
	</table>
</div>";

}else{
	if(count($WordsLike)<0){
		return;
	}
	if(count($Words)<1 && count($WordsLike)>1){
		echo "<div style='color: red;font-size: larger;'>Đây có phải từ bạn muốn tìm : </div><br />";
		foreach($WordsLike as $term){
			echo "<a style=' color: #0014FF; font-size: 17px;' href='../".$lang."/".$term["word"]."'>".$term["word"]."</a>, ";
		}
	}elseif(count($Words)<1 && count($WordsLike)<1){
		echo "<div style='color: red;font-size: larger;'>Không tìm thấy : </div><br />";
		foreach($WordsLike as $term){
			echo "<a style=' color: #0014FF; font-size: 17px;' href='../".$lang."/".$term["word"]."'>".$term["word"]."</a>, ";
		}
	}else{
	
	echo '<div class="datagridDT">
				<table>
					<thead>
						<tr>
							<th>Words</th>
							<th>Nghĩa</th>
						</tr>
					</thead>';
	
	if(count($Words)>3){
	echo				'<tfoot>
						<tr>
							<td colspan="4">
								<div id="paging">
									<ul>
										<li><a href="#"><span>Previous</span> <br/></a></li>
										<li><a href="#" class="active"><span>1</span> <br/></a></li>
										<li><a href="#"><span>2</span> <br/></a></li>
										<li><a href="#"><span>3</span> <br/></a></li>
										<li><a href="#"><span>4</span> <br/></a></li>
										<li><a href="#"><span>5</span> <br/></a></li>
										<li><a href="#"><span>Next</span> <br/></a></li>
									</ul>
								</div>
							</td>
						</tr>
					</tfoot>

					<tbody>
			';
		}
	else{
	echo				'<tfoot>
						<tr>
							<td colspan="4">
								<div id="paging">
									<ul>
										<li><a href="'.getUrl().'#D"><span>Previous</span> <br/></a></li>
										<li><a href="'.getUrl().'#D"><span>Next</span> <br/></a></li>
									</ul>
								</div>
							</td>
						</tr>
					</tfoot>

					<tbody>
			';
	}
		$i=1;
		foreach($Words as $term){
				$s = '19/11/2014';
				$date = strtotime($s);
				$date = date('d/M/Y', $date);
				if($term["dateInsert"] < $date){
				$WordMean = $term["MeanWord"];
				$WordMean = preg_replace('/=/','</h1><br /><br />----- -----Cách dùng :=',$WordMean,1);
				$WordMean = str_replace('=','<br /><b style="color: rgb(0, 238, 152);"> * </b>',$WordMean);
				
				$WordMean = preg_replace('/----- -----/',"<div class='style1'>",$WordMean,1);

				
				$WordMean = preg_replace('/@/','<tr class="alt"><td class="td1">',$WordMean,1);/// das Leben				
				$WordMean = preg_replace('/-/','</td><td class="td2"><div class="content hideContent"><h1> -',$WordMean,1);// thay cho Hr
				$WordMean = str_replace('- {','</span> <br/><span class="span1" >- {',$WordMean);
				//$WordMean = preg_replace('</span> <br/>',' ',$WordMean,1);
						
				echo $WordMean;
				echo ' </div></div>';
				}else{
					echo '<tr class="alt"><td class="td1">';
					echo $term["word"];
					echo '</td><td>';
					echo $term["MeanWord"];
					//echo '</td></tr>';
				}
				
				echo '<div class="show-more"><a href="'.getUrl().'#D'.$i.'">Show more</a></div>

					</td>

				</tr>';
				$i++;
			}
			
			
			
			
			echo '</tbody>
					</table>';
	}
}

function getUrl() {
  $url  = @( $_SERVER["HTTPS"] != 'on' ) ? 'http://'.$_SERVER["SERVER_NAME"] :  'https://'.$_SERVER["SERVER_NAME"];
  $url .= ( $_SERVER["SERVER_PORT"] !== 80 ) ? ":".$_SERVER["SERVER_PORT"] : "";
  $url .= $_SERVER["REQUEST_URI"];
  return $url;
}
?>